package com.bloody.android.Characters;

import java.util.ArrayList;

import com.bloody.android.Map.Map;

public class Gaara extends Character {
	
	private boolean isProtected=false;
	
	public Gaara(int player){
		super(player, 2, 20, 50);
		int [] attackRange = new int[2];
		for (int i= 0; i<attackRange.length; i++)
			attackRange[i]=i+2;
		super.setAttackRange(attackRange);
	}
	
	@Override
	public void setMap(Map map){
		super.setMap(map);
		GaaraAbility ability = new GaaraAbility(map, super.getAttack());
		super.setAbility(ability);
	}

	@Override
	public void setLife(int life)
	{
		if(isProtected)
			switchProtection();
		else
			super.setLife(life);
	}
	
	public void switchProtection()
	{
		isProtected = !isProtected;
	}
	
	public boolean isProtected()
	{
		return isProtected;
	}
	
	@Override
	public String toString()
	{
		return super.toString()+" "+Boolean.toString(isProtected);
	}
	
	@Override
	public void update(ArrayList<String> datas)
	{
		super.update(datas);
		isProtected = Boolean.parseBoolean(datas.get(4));
	}
}
